/*****************************************************************************/
/**
*
* @file debug.h
*
* Header file about debug functions.
*
* <1> DEBUG: print messages
* <2> DEBUG_POS(): print current position, include file, line number, function name
* <3> DEBUG_CHECK(expression): check whether or not expression is true. If not,
*							   print error and current postion
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver   Who    Date   	Changes
* ----- ---- ---------- -------------------------------------------------------
* 0.01  abu  7/30/2019 created
* 			 8/15/2019 added DEBUG_CHECK
* </pre>
*
*------------------------------------------------------------------------------
* Author: abu	E-mail:	abu_liu@aliyun.com
*				Blog:	https://blog.csdn.net/ClamerKorallen
*				Gitee:	https://gitee.com/abu_liu
*------------------------------------------------------------------------------
*
******************************************************************************/
#ifndef DEBUG_H		/* prevent circular inclusions */
#define DEBUG_H		/* by using protection macros */

#ifdef __cplusplus
	extern "C" {
#endif

/***************************** Include Files *********************************/
#include "xil_printf.h"

/************************** Constant Definitions *****************************/
#ifndef NDEBUG
#define DEBUG xil_printf
#define DEBUG_POS()	DEBUG("======================== DEBUG ========================\n\rFile: %s\n\rFunc: %s\n\rLine: %d\n\r\n\r", \
							__FILE__, __func__, __LINE__)
							
#define DEBUG_CHECK(Expression)	\
	{							\
		if ((s32)(Expression) == 0x00) {		\
			DEBUG("error found:\n\r");	\
			DEBUG_POS();		\
		}						\
	}

#endif


#ifdef __cplusplus
}
#endif

#endif

